<template>
  <div>
    <el-input v-model="file.filename" :placeholder="desFilename"></el-input>
    <span class="note">{{note}}</span><br>
    <el-input type="textarea" v-model="file.content" :placeholder="desContent"></el-input>
  </div>
</template>

<script>
  export default {
    name: "File",
    props: ["files","file","index"],
    data() {
      return {
        desContent: "请输入content",
        desFilename: "请输入文件名",
        note:""
      }
    },
    watch: {
      'file.filename': function (newVal) {
        if(this.files.filter(val => val.filename === newVal).length > 1){
          this.note="文件名重复，请重复填写";
        } else {
          this.note="";
        }
        console.log(this.files);
      }
    }
  }
</script>

<style scoped>
  .el-input{
    width:200px;
  }
</style>
